package com.insurance.modules.auth.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.insurance.entity.AuthenticationEnterpriseEntity;
import com.insurance.service.AuthenticationEnterpriseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.insurance.common.utils.PageUtils;
import com.insurance.common.utils.R;



/**
 * 企业管理
 *
 * @date 2021-02-25 17:20:28
 */
@RestController
@RequestMapping("authentication/authenticationenterprise")
public class AuthenticationEnterpriseController {

    @Autowired
    private AuthenticationEnterpriseService authenticationEnterpriseService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("authentication:authenticationenterprise:list")
    public R list(@RequestParam Map<String, Object> params, AuthenticationEnterpriseEntity authenticationEnterpriseEntity){
        QueryWrapper<AuthenticationEnterpriseEntity> queryWrapper = authenticationEnterpriseService.getQueryWrapper(authenticationEnterpriseEntity);
        PageUtils page = authenticationEnterpriseService.queryPage(params, queryWrapper);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("authentication:authenticationenterprise:info")
    public R info(@PathVariable("id") String id){
		AuthenticationEnterpriseEntity authenticationEnterprise = authenticationEnterpriseService.getById(id);
        return R.ok().put("authenticationEnterprise", authenticationEnterprise);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("authentication:authenticationenterprise:save")
    public R save(@RequestBody AuthenticationEnterpriseEntity authenticationEnterprise){
		authenticationEnterpriseService.save(authenticationEnterprise);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("authentication:authenticationenterprise:update")
    public R update(@RequestBody AuthenticationEnterpriseEntity authenticationEnterprise){
		authenticationEnterpriseService.updateById(authenticationEnterprise);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("authentication:authenticationenterprise:delete")
    public R delete(@RequestBody String[] ids){
		authenticationEnterpriseService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
